home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 46
/
Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso
/
-in_the_mag-
/
reader_requests
/
scilab
/
demos
/
graphics
/
xdemo-1.dem
< prev
next >
Wrap
Text File
|
1999-09-16
|
7KB
|
226 lines
function []=xdemo(info,str)
x_message([info;str])
execstr(str)
function []=xdemo1(filen)
// Demo of graphic primitives
//!
[lhs,rhs]=argn(0)
if rhs=1,driver("Pos"),xinit(filen);deff('[]=xshow(str)','1');end
xbasc();
plot2d([-100,500],[-100,600],[-1,-1],"022");
deff('[v]=transl(x,t)','v=x+t*ones(x)');
xset("default");
xclip('clipgrf');
x_message(["[I] function to plot a set of objects "]);
expr=['x=0:40:240;';
'boxes=[x;10*ones(x);30*ones(x);30*ones(x)];';
'xrects(boxes)'];
xdemo("[I.1] function xrects : plot rectangles",expr);
//
expr=['x=0:40:240;';
'boxes=[x;45*ones(x);30*ones(x);30*ones(x)];';
'pats=[0,4,8,12,15,xget(''white''),0];';
'xrects(boxes,pats);'];
xdemo(" fonction xrects : filling rectangles",expr);
//
expr=['x=0:40:240;';
'boxes=[x;90*ones(x);30*ones(x);30*ones(x)];';
'arcs=[boxes; 0*ones(x);64*180*ones(x)];';
'pats=[0,4,8,12,15,xget(''white''),0];';
'xarcs(arcs,pats);'];
xdemo("[I.2] xarcs(arcs,patterns)",expr);
//
expr=['x=0:40:240;';
'boxes=[x;135*ones(x);30*ones(x);30*ones(x)];';
'arcs=[boxes; 0*ones(x);64*360*ones(x)];';
'xarcs(arcs);']
xdemo("[I.2] xarcs(arcs)",expr);
//
expr0=['x1=[0,10,20,30,20,10,0];';
'y1=[15,30,30,15,0,0,15];y1=160*ones(y1)+y1;';
'xpols=[x1;transl(x1,40);transl(x1,80);transl(x1,120)'...
+ ';transl(x1,160);transl(x1,200);transl(x1,240)];';
'ypols=[y1;y1;y1;y1;y1;y1;y1];';
'xfpolys(xpols'',ypols'');'];
xdemo("[I.3] xfpolys(x,y)",expr0);
//
expr=[ expr0;
'ypols=transl(ypols,60);';
'pats=[0,4,8,12,15,xget(''white''),0];';
'xfpolys(xpols'',ypols'',pats);'];
xdemo("[I.3] xfpolys(x,y,pattern)",expr);
//
expr=[ expr0;
'ypols=transl(ypols,120);';
'xpolys(xpols'',ypols'',1:7);'];
xdemo("[I.3] xpolys(x,y,line-style)",expr);
expr=[ expr0;
'ypols=transl(ypols,180);';
'xpolys(xpols'',ypols'',-(1:7));'];
xdemo("[I.4] xpolys(x,y,line-style)",expr);
//
expr=['x=0:40:240;';
'xsegs([x;x+30*ones(x)],[(360+40)*ones(x);(360+70)*ones(x)]);']
xdemo("[I.5] xsegs(x,y)",expr);
//
expr=['x=0:40:240;';
'xarrows([x;x+30*ones(x)],[(360+70)*ones(x);(360+100)*ones(x)]);'];
xdemo(["[I.6] xarrows(x,y)"],expr);
//
expr=['x=0:100:200;';
'xnumb(x,500*ones(x),[10,20,35],1);';
'xnumb(x,550*ones(x),[10,20,35],0);';];
xdemo(["[[II.3] xnumb()"],expr);
xset("default");xclip();
xend();
function []=xdemo2(filen)
// Demo for graphic primitives
//!
[lhs,rhs]=argn(0)
if rhs=1,driver("Pos"),xinit(filen);deff('[]=xshow(str)','1');end
xbasc();
xset("default");
plot2d([-100,500],[-100,600],[-1,-1],"022");
xclip('clipgrf');
deff('[v]=transl(x,t)','v=x+t*ones(x)');
x_message(["[II] Basic Functions of drivers :"]);
expr="xrect(20,120,60,60);"
xdemo(["[II.1] xrect : draw one rectangle with current line style"],expr);
expr="xfrect(100,120,60,60);"
xdemo(["[II.1] xfrect : fill one rectangle with current pattern"],expr);
expr="xarc(20,200,50,70,0,64*(225));"
xdemo(["[II.2] xarc : draw part of an elipsis"],expr);
expr="xfarc(100,200,50,70,0,64*225);"
xdemo(["[II.2] xfarc : fill part of an elipsis"],expr);
expr0=["x=0:1:%pi;";
"[n1,n2]=size(x);";
"x1=50*sin(x)+40*ones(x);";
"y1=50*cos(x)+90*ones(x);"];
expr=[expr0;
"xset(''mark'',6,1);";
"y1=transl(y1,200);";
"xpoly(x1,y1,''marks'',0);";
"xset(''mark'',4,6);";
"x1=transl(x1,80);";
"xpoly(x1,y1,''marks'',0);"]
xdemo(["[II.3] xpoly(x,y,""marks"",0)"],expr);
expr=[expr0;"x1=transl(x1,160);";
"xpoly(x1,y1,''lines'',0);"];
xdemo(["[II.3] xpoly(x,y,""lines"",0)"],expr);
expr=[expr0;"x1=transl(x1,240);";
"xpoly(x1,y1,''lines'',1);"]
xdemo(["[II.3] xpoly(x,y,""lines"",1)"],expr);
expr=[expr0;"x1=transl(x1,320);";
"xfpoly(x1,y1,1);"]
xdemo(["[II.4] xfpoly(x,y,1)"],expr);
expr=["xset(''font'',2,2);";
"xstring(200,200,''Character string'',0,0);";
"xstring(200,250,''Character string'',0,1);";
"xstring(400,300,''Chaine '',45,0);"];
xdemo(["[II.5] xstring"],expr);
expr=["rect=xstringl(350,200,''Character string'');";
"xrect(rect(1),rect(2),rect(3),rect(4));"]
xdemo(["[II.6] xstringl";],expr);
xend();
xset("default");xclip();
function []=xdemo3()
// back to gcontext defaults values.
xbasc();
xset("default");
plot2d([-100,500],[-100,600],[-1,-1],"022");
xclip('clipgrf');
deff('[v]=transl(x,t)','v=x+t*ones(x)');
x_message(["[IV] Setting graphic context values"]);
expr=["x=0:0.2:2*%pi;";
"x1=[sin(x);10*sin(x)];";
"y1=[cos(x);10*cos(x)];";
"xsegs(10*x1+200*ones(x1),10*y1+200*ones(y1));"];
xdemo(["[IV.2] segments"],expr);
expr=["xrect(150,460,100,150);";
"xclip(150,460,100,150);";
"x=0:0.2:2*%pi;";
"x1=[sin(x);10*sin(x)];";
"y1=[cos(x);10*cos(x)];";
"y1=transl(y1,20);";
"xsegs(10*x1+200*ones(x1),10*y1+200*ones(y1));";
"xset(''clipgrf'');";];
xdemo(["[IV.2] segments+clipping zone"],expr);
expr=["xset(''dashes'',1,2,2);";
"xget(''dashes'',1);";
"xrect(140,470,120,170);"];
xdemo(["[IV.4] Setting a dash style"],expr);
//
expr=["xset(''default'');";
"xset(''font'',2,0);";
"xstring(0,130,''Scilab'');";
"xset(''font'',2,1);";
"xstring(0,150,''Scilab'');";
"xset(''font'',2,2);";
"xstring(0,170,''Scilab'');";
"xset(''font'',2,3);";
"xstring(0,200,''Scilab'');";
"xset(''font'',2,4);";
"xstring(0,230,''Scilab'');";
"xset(''font'',2,5);";
"xstring(0,270,''Scilab'');";
"xset(''font'',3,5);";
"xstring(0,310,''Scilab'');";
"xset(''font'',4,5);";
"xstring(0,350,''Scilab'');"]
xdemo(["[IV.5] Setting font style and size"],expr);
//expr=["xset(''line mode'',1);";
// "xpoly([300,80,0,-80,0],[100,0,80,0,-80],''lines'',0);"];
//xdemo(["[IV.6] Relative line mode for drawing functions"],expr);
expr=["xset(''line mode'',0);";
"xlfont(''-*-helvetica-bold-r-normal--*-%s0-*-*-p-*-*-1'',6);";
"xset(''font'',6,3);";
"xstring(100,260,''helVB'',0,1);"];
xdemo(["[IV.7] Loading a new font hlevB is now font 6"],expr);
//
expr0=["x1=[350,400,450];";
"[n1,n2]=size(x1);";
"y1=300*ones(x1);"];
expr=[expr0;
"xset(''mark'',6,2);";
"xpoly(x1,y1,''marks'',0);"];
xdemo(["[IV.8] changing current mark"],expr);
expr=[expr0;
"xset(''mark'',7,2);";
"xpoly(x1,y1+50*ones(x1),''marks'',0);";
"xset(''mark'',8,3);";
"xpoly(x1,y1+100*ones(x1),''marks'',0);"];
xdemo(["[IV.8] changing current mark"],expr);
expr=["xset(''thickness'',5);";
"xrect(400,200,50,100);";];
xdemo(["[IV.9] Thickness)"],expr);
xset("default");
expr=["xfrect(400,50,50,100);";
"xclea(410,50,10,100);"];
xdemo(["[V.2] Clear a rectangle"],expr);
xend();
xset("default");
xclip();
function []=xdemo4(display)
[lhs,rhs]=argn(0)
if rhs=0,display="unix:0.0",end
xbasc();
xset("default");
plot2d([-100,500],[-100,600],[-1,-1],"022");
plot3d();
x_message(["[V] General functions"]);
expr=["xinit(display);";
"plot2d()";];
xdemo(["[V.1] Creating a new window"],expr);
expr=["xset(''window'',0);";
"xselect();";]
xdemo("[V.2] Selecting and raising window 0]",expr);
xend();
xset("default");